﻿''
''Copyright Zac McKenzie 2012
''

'This class manages the ozTivoListings.
'It reads through the relevant listings a certain number of days into the future and loads the individual TV Guide Listing
Imports sxl = System.Xml.Linq
Imports System.Linq

Public Class ozTivoListing


    Public tvGuideListings_List As List(Of tvGuideListing) = New List(Of tvGuideListing)

    Public Sub New()
        config.loadConfig()             'load the config info to get the list of channels
    End Sub

    Public Sub loadTvProgramListings()

        tvGuideListings_List.Clear()
        For dOffset As Integer = 0 To 5
            'determine the date of the schedule to download
            Dim d = Now.AddDays(dOffset).Year & "-" & Now.AddDays(dOffset).Month.ToString.PadLeft(2, "0") & "-" & Now.AddDays(dOffset).Day.ToString.PadLeft(2, "0")

            'download the above date for each possible channel
            For Each svcDetail As svc In config.channelList.Values
                If svcDetail.channelName = "Unknown" Then Continue For
                Dim tvP = New tvGuideListing(svcDetail, d)

                tvGuideListings_List.Add(tvP)
            Next

        Next dOffset
    End Sub

End Class